import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		// 交易对
		defaultSymbol: 'eth_st',
		// K线
		kilneData: {

		},
		kilneTime: '',
		currentMarketData: {},
		createKline: true,
		language: 'zh-cn',
		logged: uni.getStorageSync('logged'),
		//tabbar 遮罩
		tabbarView: {
			show: ()=>{},
			hide: ()=>{}
		}
	},
	mutations: {
		setTabbarView(state, obj) {
			state.tabbarView = obj;
		},
		login(state, provider) {
			console.log(state)
			console.log(provider)
			state.login = true;
			state.token = provider.token;
			state.userName = provider.userName;
			state.avatarUrl = provider.avatarUrl;
		},
		logout(state) {
			state.login = false;
			state.token = '';
			state.userName = '';
			state.avatarUrl = '';
		},
		setKlineTime(state, obj) {
			if (obj === '1min') {
				state.kilneTime = 'min';
				return;
			}
			state.kilneTime = obj;
		},
		setKlineData(state, obj) {
			if (obj === 3) {
				state.kilneData = {};
				return;
			}
			state.kilneData = obj;
		}
	}
})
export default store
